/**
 * Definition for a binary tree node.

 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */

function TreeNode(val, left, right) {
    this.val = (val===undefined ? 0 : val)
    this.left = (left===undefined ? null : left)
    this.right = (right===undefined ? null : right)
}
 var isSymmetric = function(root) {
    function loop(node1, node2){
        if(node1 && node2){
            if(node1.val !== node1.val){
                return false
            }
            return loop(node1.left, node2.right) && loop(node1.right, node2.left)
            
        }else if(node1 && !node2){
            return false
        }else if( !node1 && node2){
            return false
        }
        
    }
    return loop(root, root)
}
